#include <iostream>
#include <stack>
using namespace std;
//使用非递归 计算
/*
 * p0(x)=1
 * p1(x)=2*x
 * pn(x)=2x*p(n-1)(x)-2(n-1)p(n-2)(x)
 * */
const int N = 10;
typedef pair<int, int> PII;

int p(int n, int x)
{
    PII st[N];
    int top = -1;
    int f0 = 1, f1 = 2 * x;
    for (int i = n; i >= 2; i--)
        st[++top].first = i;
    while (top >= 0)
    {
        st[top].second = 2 * x * f1 - x * (st[top].first - 1) * f0;
        f0 = f1;
        f1 = st[top].second;
        top--;
    }
    if (n == 0)
        return f0;
    return f1;
}
int main()
{
    for (int i = 1; i <= 4; i++)
        cout << p(i, 2) << endl;
    return 0;
}